[data transfer method for universal serial bus device]

ABSTRACT

A data transfer method for a Universal Serial Bus (USB) device is provided. The data transfer rate of a bulk transfer type transmission in the USB is detected first for selecting a transfer type transmission having a better data transfer rate between the bulk transfer type transmission in the USB and an interrupt transfer type transmission in the USB, so as to ensure the data transfer bandwidth in the USB is better utilized by the USB device.

BACKGROUND OF INVENTION

1. Field of the Invention

The present invention relates to a Universal Serial Bus (USB) device,and more particularly, to a data transfer method for a USB device.

2. Description of the Related Art

The Universal Serial Bus (abbreviated as USB) is a connection interfaceused in the peripheral device of a computer device such as a desktopcomputer, a notebook computer, and a Personal Digital Assistant(abbreviated as PDA). Since it is hot-swappable, the user can easily addthe peripheral device into or remove it from the computer device, andthe desktop computer, notebook computer, and PDA can automaticallydetect the peripheral device for maintaining its normal operation whileit is being added into or removed from the computer device. Therefore,the USB interface has been widely applied in the peripheral device suchas a keyboard, a mouse, a network adapter, and a printer. Moreover,since it is convenient in adding or removing the peripheral device usingthe USB interface as a computer peripheral device, a storage deviceusing the USB interface has been developed to facilitate the datatransfer and data sharing between different computers.

There are four kinds of transfer type transmission defined in the USBprotocol (include bulk, control, interrupt and isochronous). The mostfamiliar transfer type transmission is bulk transfer. The bulk transfertype transmission is commonly used in the USB storage device fortransmitting a great amount of data. The bulk transfer type transmissionhas a USB hand shake mechanism, thus it can guarantee the correctness ofthe data transfer. However, among various USB transmissions, since thebulk transfer type transmission cannot guarantee the data transferbandwidth, when several USB devices are using a USB simultaneously, thebandwidth of the device using the bulk transfer type transmission isdistributed and shared by all USB devices in the USB and the transferrate is degraded.

FIG. 1 is a transfer rate sharing diagram of a USB which connects todifferent number of the USB devices using the bulk transfer typetransmission. It is assumed that the maximum data transfer rate for theUSB is 48 Mbytes/sec, and there are A, B, and C three devices eachhaving only a bulk endpoint. In FIG. 1(a), where only device A isconnected to the USB, the data transfer rate of device A is up to 48Mbytes/sec. In FIG. 1(b), where both devices A and B are connected toone USB and use the USB simultaneously, the shared data transfer ratefor each device A and B is 24 Mbytes/sec, respectively. In FIG. 1(c),where all device A, B, and C are connected to the USB and use the USBsimultaneously, the shared data transfer rate for each device A, B, andC is 16 Mbytes/sec, respectively. In other words, when the number of theUSB devices connected to the USB increases, the data transfer rate foreach USB device is decreased due to the shared bandwidth, thus it cannotmeet the desired expectation.

SUMMARY OF INVENTION

In the light of the preface, it is an object of the present invention toprovide a data transfer method for a USB device. The method detects adata transfer rate of a bulk transfer type transmission in the USBfirst, and when the data transfer rate of the bulk transfer typetransmission in the USB is lower than a predetermined value, the methodselects an interrupt transfer type transmission in the USB to transferthe data in the USB device, so as to ensure the transfer bandwidththereof is better utilized.

In order to achieve the object mentioned above and other advantages, thepresent invention provides a data transfer method for a USB device. Themethod comprises: connecting a USB device to a USB; detecting anddetermining whether the data transfer rate of the bulk transfer typetransmission in the USB is lower than a predetermined value; and if thedata transfer rate of the bulk transfer type transmission in the USB islower than the predetermined value, swapping to use the interrupttransfer type transmission in the USB to transfer the data in the USBdevice, so as to ensure the transfer bandwidth thereof is betterutilized.

In an embodiment of the present invention, the data transfer method forthe USB device further comprises: when the data transfer rate of thebulk transfer type transmission in the USB is not lower than thepredetermined value, the bulk transfer type transmission in the USB totransfer the data in the USB device is used.

In an embodiment of the present invention, the data transfer method forthe USB device further comprises: when using the interrupt transfer typetransmission in the USB to transfer the data in the USB device for apredetermined period of time, swapping back to use the bulk transfertype transmission to transfer the data in the USB device for trying touse a higher transfer rate to transfer the data in the USB device.

In an embodiment of the present invention, the predetermined value setin the data transfer method for the USB device is preferably a datatransfer rate which is guaranteed by the interrupt transfer typetransmission in the USB.

In summary, by applying a data transfer method for the USB deviceprovided by the present invention, a data transfer rate of the bulktransfer type transmission in the USB is detected first, and when thedata transfer rate of the bulk transfer type transmission in the USB islower than a predetermined value, an interrupt transfer typetransmission in the USB is selected to transfer the data in the USBdevice, so as to ensure the transfer bandwidth thereof is betterutilized.

BRIEF DESCRIPTION OF DRAWINGS

The accompanying drawings are included to provide a furtherunderstanding of the invention, and are incorporated in and constitute apart of this specification. The drawings illustrate embodiments of theinvention, and together with the description, serve to explain theprinciples of the invention.

FIG. 1 is a transfer rate sharing diagram of a USB which connects todifferent number of the USB devices using the bulk transfer typetransmission.

FIG. 2 is a flow chart illustrating a data transfer method for the USBdevice according to a preferred embodiment of the present invention.

FIG. 3 is a transfer rate sharing diagram of a USB which connects todifferent number of the USB devices using the bulk transfer typetransmission and the interrupt transfer type transmission.

DETAILED DESCRIPTION

As mentioned above, the bulk transfer type transmission is commonly usedin the USB storage device such as the flash disk for transmitting agreat amount of data. However, since the bulk transfer type transmissionusing the USB cannot guarantee the data transfer bandwidth when multipleUSB devices use one USB bus simultaneously, the bandwidth of the USB isdistributed and shared by all USB devices inserted into the same USB busand accordingly, the transfer rate is degraded. Therefore, in order toresolve the above problem, a data transfer method for the USB device isprovided by the present invention. The method is suitable for a USBdevice which predefines two sets of descriptor, wherein one set definesthe USB device as a bulk endpoint, and the other set defines the USBdevice as an interrupt endpoint, so as to ensure the transfer bandwidththereof is better utilized while still maintaining the generalcharacteristic of the USB device.

FIG. 2 is a flow chart illustrating a data transfer method for the USBdevice according to a preferred embodiment of the present invention. Asshown in the diagram, in step S210, whether or not a USB device isinserted into a USB host is detected, that is whether the USB device isconnected to the USB is detected, if yes, the process enters into stepS220 for detecting and determining whether or not the data transfer rateof the bulk transfer type transmission in the USB is lower than apredetermined value.

When it is determined in step S220 that the data transfer rate of thebulk transfer type transmission in the USB is lower than thepredetermined value, the process enters into step S230 for swapping touse the interrupt transfer type transmission in the USB to transfer thedata in the USB device. Because having the USB hand shake mechanism, theinterrupt transfer type transmission of the USB guarantees thecorrectness of the data transfer, and it is also a transfer type thatguarantees the transfer bandwidth among various USB transmissions.Therefore, no matter how many USB devices are connected to the USBsimultaneously, it is guaranteed that a certain data transfer bandwidthis reserved. Therefore, it is ensured that the transfer bandwidththereof is better utilized even when the data transfer rate of the bulktransfer type transmission in the USB is degraded.

Referring to FIG. 3, a transfer rate sharing diagram of a USB connectingto different number of the USB devices using the bulk transfer typetransmission and the interrupt transfer type transmission is shown. Itis assumed that the maximum data transfer rate for the USB is 48Mbytes/sec, the data transfer bandwidth reserved for the interrupttransfer type transmission in the USB is 24 Mbytes/sec, and there arefour devices A, B, C, and D, wherein each of the devices B, C, and D hasa bulk endpoint. As shown in FIG. 3(a), when devices A, B, and C are useone USB simultaneously, the shared data transfer rate for device A usedin the data transfer method for the USB device according to the presentinvention is 24 Mbytes/sec, and the shared data transfer rate for eachdevice B and C is 12 Mbytes/sec, respectively. As shown in FIG. 3(b),when devices A, B, C, and D are using the USB simultaneously, the shareddata transfer rate for device A used in the data transfer method for theUSB device according to the present invention is still 24 Mbytes/sec,whereas the shared data transfer rate for each device B, C, and D is 8Mbytes/sec, respectively. In other words, it is ensured that the datatransfer rate of device A used in the data transfer method for the USBdevice according to the present invention is 24 Mbytes/sec.

Referring to FIG. 2, after swapping to use the interrupt transfer typetransmission in the USB to transfer the data in the USB device in stepS230, the process enters into step S240 for determining whether or notthe predetermined time is due. If the predetermined time is due, theprocess enters into step S250 for swapping to use the bulk transfer typetransmission in the USB to transfer the data in the USB deviceattempting to use a higher data transfer rate to transfer data. Thereason for having this step is because the number of the USB devicesconnected to the USB is dynamically changed. Therefore, when the numberof the USB devices connected to the USB is decreased or the requireddata transfer bandwidth is reduced, the data transfer rate of the bulktransfer type transmission in the USB is higher than the predeterminedvalue again. Meanwhile, the bulk transfer type transmission in the USBis used to transfer data, such that the USB bandwidth is fully utilized.

In addition, if it is determined in step S220 that the data transferrate of the bulk transfer type transmission in the USB is not lower thanthe predetermined value, the process enters into step S250 where thebulk transfer type transmission in the USB is used to transfer the datain the USB device.

Wherein, the predetermined value set in the data transfer method for theUSB device is preferably a data transfer rate which is guaranteed by theinterrupt transfer type transmission in the USB, for example, 24Mbytes/sec as mentioned above. Therefore, when using the data transfermethod for the USB device provided by the present invention to transferthe data in the USB device, it is possible to select a transmissionmethod with a higher data transfer rate between the data transfer rateof the bulk transfer type transmission in the USB and the data transferrate of the interrupt transfer type transmission in the USB, so as toensure the transfer bandwidth thereof is better utilized.

Although the invention has been described with reference to a particularembodiment thereof, it will be apparent to one of the ordinary skill inthe art that modifications to the described embodiment may be madewithout departing from the spirit of the invention. Accordingly, thescope of the invention will be defined by the attached claims not by theabove detailed description.

1. A data transfer method for a USB device, comprising: connecting a USBdevice to a USB; determining whether a data transfer rate of a bulktransfer type transmission in the USB is lower than a predeterminedvalue; and swapping to use an interrupt transfer type transmission inthe USB to transfer the data in the USB device when the data transferrate of the bulk transfer type transmission in the USB is lower than thepredetermined value.
 2. The data transfer method for the USB device ofclaim 1, further comprising: using the bulk transfer type transmissionin the USB to transfer the data in the USB device when the data transferrate of the bulk transfer type transmission in the USB is not lower thanthe predetermined value.
 3. The data transfer method for the USB deviceof claim 1, further comprising: after using the interrupt transfer typetransmission in the USB to transfer the data in the USB device for apredetermined period of time, swapping to use the bulk transfer typetransmission in the USB to transfer the data in the USB device.
 4. Thedata transfer method for the USB device of claim 1, wherein thepredetermined value is a data transfer rate which is guaranteed by theinterrupt transfer type transmission in the USB.
 5. A data transfermethod for a USB device, comprising: determining whether a data transferrate of a bulk transfer type transmission in a USB connected to a USBdevice is lower than a predetermined value; and selecting an interrupttransfer type transmission in the USB to transfer a data in the USBdevice when the data transfer rate of the bulk transfer typetransmission in the USB is lower than the predetermined value.
 6. Thedata transfer method for the USB device of claim 5, further comprising:using the bulk transfer type transmission in the USB to transfer thedata in the USB device when the data transfer rate of the bulk transfertype transmission in the USB is not lower than the predetermined value.7. The data transfer method for the USB device of claim 5, furthercomprising: after using the interrupt transfer type transmission in theUSB to transfer the data in the USB device for a predetermined period oftime, swapping to the bulk transfer type transmission in the USB totransfer the data in the USB device.
 8. The data transfer method for theUSB device of claim 5, wherein the predetermined value is a datatransfer rate which is guaranteed by the interrupt transfer typetransmission in the USB.